#!/usr/bin/python
# coding: utf-8

# STM32 definitions

# Tables taken from http://www.atollic.com/index.php/targets/armtargetsupport/arm-stm
hwtable = u"""
• STM32VL_Discovery     STM32F100RB     Cortex-M3
• STM32L_Discovery      STM32L152RB     Cortex-M3
• STM32F0_Discovery     STM32F051R8     Cortex-M0
• NUCLEO-F030R8         STM32F030R8     Cortex-M0
• NUCLEO-F103RB         STM32F103RB     Cortex-M3
• NUCLEO-L053R8         STM32L053R8     Cortex-M0+
• NUCLEO-L152RE         STM32L152RE     Cortex-M3
• NUCLEO-F401RE         STM32F401RE     Cortex-M4
• STM32F3_Discovery     STM32F303VC     Cortex-M4
• STM32F4_Discovery     STM32F407VG     Cortex-M4
• STM32F401_Discovery   STM32F401VC     Cortex-M4
• STM32F429I_Discovery  STM32F429ZI     Cortex-M4
• STM320518-EVAL        STM32F051R8     Cortex-M0
• STM32052B-EVAL        STM32F052RB     Cortex-M0
• STM3210E-EVAL         STM32F103ZE     Cortex-M3
• STM3210E-EVAL_XL      STM32F103ZG     Cortex-M3
• STM3210B-EVAL         STM32F103VB     Cortex-M3
• STM3210C-EVAL         STM32F107VC     Cortex-M3
• STM32100B-EVAL        STM32F100VB     Cortex-M3
• STM32100E-EVAL        STM32F100ZE     Cortex-M3
• STM32L152-EVAL        STM32L152VB     Cortex-M3
• STM32L152D-EVAL       STM32L152ZD     Cortex-M3
• STM322xG-EVAL         STM32F207IG     Cortex-M3
• STM3221G-EVAL         STM32F217IG     Cortex-M3
• STM32303C-EVAL        STM32F303VC     Cortex-M4
• STM32373C-EVAL        STM32F373VC     Cortex-M4
• STM324xG-EVAL         STM32F407IG     Cortex-M4
• STM32437I-EVAL        STM32F437II     Cortex-M4
• STM32429I-EVAL        STM32F429NI     Cortex-M4
• STM32439I-EVAL        STM32F439NI     Cortex-M4
• STM32W_MB851          STM32W108CB     Cortex-M3
• IAR_STM32F103ZE       STM32F103ZE     Cortex-M3
• KEIL_MCBSTM32         STM32F103RB     Cortex-M3
"""

cputable = u"""
# STM32 F0 Entry-level devices
• STM32F030C6 	Cortex-M0 	FLASH: 32 	RAM: 4
• STM32F030C8 	Cortex-M0 	FLASH: 64 	RAM: 8
• STM32F030F4 	Cortex-M0 	FLASH: 16 	RAM: 4
• STM32F030K6 	Cortex-M0 	FLASH: 32 	RAM: 4
• STM32F030R8 	Cortex-M0 	FLASH: 64 	RAM: 8
• STM32F031C4 	Cortex-M0 	FLASH: 16 	RAM: 4
• STM32F031C6 	Cortex-M0 	FLASH: 32 	RAM: 4
• STM32F031F4 	Cortex-M0 	FLASH: 16 	RAM: 4
• STM32F031F6 	Cortex-M0 	FLASH: 32 	RAM: 4
• STM32F031G4 	Cortex-M0 	FLASH: 16 	RAM: 4
• STM32F031G6 	Cortex-M0 	FLASH: 32 	RAM: 4
• STM32F031K4 	Cortex-M0 	FLASH: 16 	RAM: 4
• STM32F031K6 	Cortex-M0 	FLASH: 32 	RAM: 4
• STM32F042C4 	Cortex-M0 	FLASH: 16 	RAM: 6
• STM32F042C6 	Cortex-M0 	FLASH: 32 	RAM: 6
• STM32F042F4 	Cortex-M0 	FLASH: 16 	RAM: 6
• STM32F042F6 	Cortex-M0 	FLASH: 32 	RAM: 6
• STM32F042G4 	Cortex-M0 	FLASH: 16 	RAM: 6
• STM32F042G6 	Cortex-M0 	FLASH: 32 	RAM: 6
• STM32F042K4 	Cortex-M0 	FLASH: 16 	RAM: 6
• STM32F042K6 	Cortex-M0 	FLASH: 32 	RAM: 6
• STM32F042T4 	Cortex-M0 	FLASH: 16 	RAM: 6
• STM32F042T6 	Cortex-M0 	FLASH: 32 	RAM: 6
• STM32F050C4 	Cortex-M0 	FLASH: 16 	RAM: 4
• STM32F050C6 	Cortex-M0 	FLASH: 32 	RAM: 4
• STM32F050F4 	Cortex-M0 	FLASH: 16 	RAM: 4
• STM32F050F6 	Cortex-M0 	FLASH: 32 	RAM: 4
• STM32F050G4 	Cortex-M0 	FLASH: 16 	RAM: 4
• STM32F050G6 	Cortex-M0 	FLASH: 32 	RAM: 4
• STM32F050K4 	Cortex-M0 	FLASH: 16 	RAM: 4
• STM32F050K6 	Cortex-M0 	FLASH: 32 	RAM: 4
• STM32F051C4 	Cortex-M0 	FLASH: 16 	RAM: 8
• STM32F051C6 	Cortex-M0 	FLASH: 32 	RAM: 8
• STM32F051C8 	Cortex-M0 	FLASH: 64 	RAM: 8
• STM32F051CB 	Cortex-M0 	FLASH: 128 	RAM: 8
• STM32F051K4 	Cortex-M0 	FLASH: 16 	RAM: 8
• STM32F051K6 	Cortex-M0 	FLASH: 32 	RAM: 8
• STM32F051K8 	Cortex-M0 	FLASH: 64 	RAM: 8
• STM32F051R4 	Cortex-M0 	FLASH: 16 	RAM: 8
• STM32F051R6 	Cortex-M0 	FLASH: 32 	RAM: 8
• STM32F051R8 	Cortex-M0 	FLASH: 64 	RAM: 8
• STM32F051RB 	Cortex-M0 	FLASH: 128 	RAM: 8
• STM32F051VB 	Cortex-M0 	FLASH: 128 	RAM: 8
• STM32F071CB 	Cortex-M0 	FLASH: 128 	RAM: 16
• STM32F071RB 	Cortex-M0 	FLASH: 128 	RAM: 16
• STM32F071VB 	Cortex-M0 	FLASH: 128 	RAM: 16
• STM32F052C8 	Cortex-M0 	FLASH: 64 	RAM: 16
• STM32F052CB 	Cortex-M0 	FLASH: 128 	RAM: 16
• STM32F052R8 	Cortex-M0 	FLASH: 64 	RAM: 16
• STM32F052RB 	Cortex-M0 	FLASH: 128 	RAM: 16
• STM32F052V8 	Cortex-M0 	FLASH: 64 	RAM: 16
• STM32F052VB 	Cortex-M0 	FLASH: 128 	RAM: 16
• STM32F072C8 	Cortex-M0 	FLASH: 64 	RAM: 16
• STM32F072CB 	Cortex-M0 	FLASH: 128 	RAM: 16
• STM32F072R8 	Cortex-M0 	FLASH: 64 	RAM: 16
• STM32F072RB 	Cortex-M0 	FLASH: 128 	RAM: 16
• STM32F072V8 	Cortex-M0 	FLASH: 64 	RAM: 16
• STM32F072VB 	Cortex-M0 	FLASH: 128 	RAM: 16
• STM32F078CB 	Cortex-M0 	FLASH: 128 	RAM: 16
• STM32F078VB 	Cortex-M0 	FLASH: 128 	RAM: 16

 
# STM32 L0 ultra-low-power devices
• STM32L051C6 	Cortex-M0+ 	FLASH: 32 	RAM: 8
• STM32L051K6 	Cortex-M0+ 	FLASH: 32 	RAM: 8
• STM32L051R6 	Cortex-M0+ 	FLASH: 32 	RAM: 8
• STM32L051T6 	Cortex-M0+ 	FLASH: 32 	RAM: 8
• STM32L051C8 	Cortex-M0+ 	FLASH: 64 	RAM: 8
• STM32L051K8 	Cortex-M0+ 	FLASH: 64 	RAM: 8
• STM32L051R8 	Cortex-M0+ 	FLASH: 64 	RAM: 8
• STM32L051T8 	Cortex-M0+ 	FLASH: 64 	RAM: 8
• STM32L052C6 	Cortex-M0+ 	FLASH: 32 	RAM: 8
• STM32L052K6 	Cortex-M0+ 	FLASH: 32 	RAM: 8
• STM32L052R6 	Cortex-M0+ 	FLASH: 32 	RAM: 8
• STM32L052T6 	Cortex-M0+ 	FLASH: 32 	RAM: 8
• STM32L052C8 	Cortex-M0+ 	FLASH: 64 	RAM: 8
• STM32L052K8 	Cortex-M0+ 	FLASH: 64 	RAM: 8
• STM32L052R8 	Cortex-M0+ 	FLASH: 64 	RAM: 8
• STM32L052T8 	Cortex-M0+ 	FLASH: 64 	RAM: 8
• STM32L053C6 	Cortex-M0+ 	FLASH: 32 	RAM: 8
• STM32L053R6 	Cortex-M0+ 	FLASH: 32 	RAM: 8
• STM32L053C8 	Cortex-M0+ 	FLASH: 64 	RAM: 8
• STM32L053R8 	Cortex-M0+ 	FLASH: 64 	RAM: 8
• STM32L062K8 	Cortex-M0+ 	FLASH: 64 	RAM: 8
• STM32L063C8 	Cortex-M0+ 	FLASH: 64 	RAM: 8
• STM32L063R8 	Cortex-M0+ 	FLASH: 64 	RAM: 8

 
# STM32 High density devices
• STM32F101RC 	Cortex-M3 	FLASH: 256 	RAM: 32
• STM32F101VC 	Cortex-M3 	FLASH: 256 	RAM: 32
• STM32F101ZC 	Cortex-M3 	FLASH: 256 	RAM: 32
• STM32F103RC 	Cortex-M3 	FLASH: 256 	RAM: 48
• STM32F103VC 	Cortex-M3 	FLASH: 256 	RAM: 48
• STM32F103ZC 	Cortex-M3 	FLASH: 256 	RAM: 48
• STM32F101RD 	Cortex-M3 	FLASH: 384 	RAM: 48
• STM32F101VD 	Cortex-M3 	FLASH: 384 	RAM: 48
• STM32F101ZD 	Cortex-M3 	FLASH: 384 	RAM: 48
• STM32F103RD 	Cortex-M3 	FLASH: 384 	RAM: 64
• STM32F103VD 	Cortex-M3 	FLASH: 384 	RAM: 64
• STM32F103ZD 	Cortex-M3 	FLASH: 384 	RAM: 64
• STM32F101RE 	Cortex-M3 	FLASH: 512 	RAM: 48
• STM32F101VE 	Cortex-M3 	FLASH: 512 	RAM: 48
• STM32F101ZE 	Cortex-M3 	FLASH: 512 	RAM: 48
• STM32F103RE 	Cortex-M3 	FLASH: 512 	RAM: 64
• STM32F103VE 	Cortex-M3 	FLASH: 512 	RAM: 64
• STM32F103ZE 	Cortex-M3 	FLASH: 512 	RAM: 64

 
# STM32 Medium density devices
• STM32F101T8 	Cortex-M3 	FLASH: 64 	RAM: 10
• STM32F101TB 	Cortex-M3 	FLASH: 128 	RAM: 16
• STM32F101C8 	Cortex-M3 	FLASH: 64 	RAM: 10
• STM32F101R8 	Cortex-M3 	FLASH: 64 	RAM: 10
• STM32F101V8 	Cortex-M3 	FLASH: 64 	RAM: 10
• STM32F102C8 	Cortex-M3 	FLASH: 64 	RAM: 10
• STM32F102R8 	Cortex-M3 	FLASH: 64 	RAM: 10
• STM32F103T8 	Cortex-M3 	FLASH: 64 	RAM: 20
• STM32F103C8 	Cortex-M3 	FLASH: 64 	RAM: 20
• STM32F103R8 	Cortex-M3 	FLASH: 64 	RAM: 20
• STM32F103V8 	Cortex-M3 	FLASH: 64 	RAM: 20
• STM32F101CB 	Cortex-M3 	FLASH: 128 	RAM: 16
• STM32F101RB 	Cortex-M3 	FLASH: 128 	RAM: 16
• STM32F101VB 	Cortex-M3 	FLASH: 128 	RAM: 16
• STM32F102CB 	Cortex-M3 	FLASH: 128 	RAM: 16
• STM32F102RB 	Cortex-M3 	FLASH: 128 	RAM: 16
• STM32F103CB 	Cortex-M3 	FLASH: 128 	RAM: 20
• STM32F103RB 	Cortex-M3 	FLASH: 128 	RAM: 20
• STM32F103VB 	Cortex-M3 	FLASH: 128 	RAM: 20
• STM32F103TB 	Cortex-M3 	FLASH: 128 	RAM: 20

 
# STM32 Low density devices
• STM32F101T4 	Cortex-M3 	FLASH: 16 	RAM: 4
• STM32F101C4 	Cortex-M3 	FLASH: 16 	RAM: 4
• STM32F101R4 	Cortex-M3 	FLASH: 16 	RAM: 4
• STM32F102C4 	Cortex-M3 	FLASH: 16 	RAM: 4
• STM32F102R4 	Cortex-M3 	FLASH: 16 	RAM: 4
• STM32F103T4 	Cortex-M3 	FLASH: 16 	RAM: 6
• STM32F103C4 	Cortex-M3 	FLASH: 16 	RAM: 6
• STM32F103R4 	Cortex-M3 	FLASH: 16 	RAM: 6
• STM32F101T6 	Cortex-M3 	FLASH: 32 	RAM: 6
• STM32F101C6 	Cortex-M3 	FLASH: 32 	RAM: 6
• STM32F101R6 	Cortex-M3 	FLASH: 32 	RAM: 6
• STM32F102C6 	Cortex-M3 	FLASH: 32 	RAM: 6
• STM32F102R6 	Cortex-M3 	FLASH: 32 	RAM: 6
• STM32F103T6 	Cortex-M3 	FLASH: 32 	RAM: 10
• STM32F103C6 	Cortex-M3 	FLASH: 32 	RAM: 10
• STM32F103R6 	Cortex-M3 	FLASH: 32 	RAM: 10

 
# STM32 Connectivity line devices
• STM32F105R8 	Cortex-M3 	FLASH: 64 	RAM: 64
• STM32F105V8 	Cortex-M3 	FLASH: 64 	RAM: 64
• STM32F105RB 	Cortex-M3 	FLASH: 128 	RAM: 64
• STM32F105VB 	Cortex-M3 	FLASH: 128 	RAM: 64
• STM32F107RB 	Cortex-M3 	FLASH: 128 	RAM: 64
• STM32F107VB 	Cortex-M3 	FLASH: 128 	RAM: 64
• STM32F105RC 	Cortex-M3 	FLASH: 256 	RAM: 64
• STM32F105VC 	Cortex-M3 	FLASH: 256 	RAM: 64
• STM32F107RC 	Cortex-M3 	FLASH: 256 	RAM: 64
• STM32F107VC 	Cortex-M3 	FLASH: 256 	RAM: 64

 
# STM32 Low density Value Line devices
• STM32F100C6 	Cortex-M3 	FLASH: 32 	RAM: 4
• STM32F100R6 	Cortex-M3 	FLASH: 32 	RAM: 4
• STM32F100C4 	Cortex-M3 	FLASH: 16 	RAM: 4
• STM32F100R4 	Cortex-M3 	FLASH: 16 	RAM: 4

 
# STM32 Medium density Value Line devices
• STM32F100CB 	Cortex-M3 	FLASH: 128 	RAM: 8
• STM32F100RB 	Cortex-M3 	FLASH: 128 	RAM: 8
• STM32F100VB 	Cortex-M3 	FLASH: 128 	RAM: 8
• STM32F100C8 	Cortex-M3 	FLASH: 64 	RAM: 8
• STM32F100R8 	Cortex-M3 	FLASH: 64 	RAM: 8
• STM32F100V8 	Cortex-M3 	FLASH: 64 	RAM: 8

 
# STM32 XL density devices
• STM32F103ZG 	Cortex-M3 	FLASH: 1024 	RAM: 96
• STM32F103ZF 	Cortex-M3 	FLASH: 768 	RAM: 96
• STM32F103VG 	Cortex-M3 	FLASH: 1024 	RAM: 96
• STM32F103VF 	Cortex-M3 	FLASH: 768 	RAM: 96
• STM32F103RG 	Cortex-M3 	FLASH: 1024 	RAM: 96
• STM32F103RF 	Cortex-M3 	FLASH: 768 	RAM: 96
• STM32F101ZG 	Cortex-M3 	FLASH: 1024 	RAM: 80
• STM32F101ZF 	Cortex-M3 	FLASH: 768 	RAM: 80
• STM32F101VG 	Cortex-M3 	FLASH: 1024 	RAM: 80
• STM32F101VF 	Cortex-M3 	FLASH: 768 	RAM: 80
• STM32F101RG 	Cortex-M3 	FLASH: 1024 	RAM: 80
• STM32F101RF 	Cortex-M3 	FLASH: 768 	RAM: 80

 
# STM32 High density Value Line devices
• STM32F100RC 	Cortex-M3 	FLASH: 256 	RAM: 24
• STM32F100VC 	Cortex-M3 	FLASH: 256 	RAM: 24
• STM32F100ZC 	Cortex-M3 	FLASH: 256 	RAM: 24
• STM32F100RD 	Cortex-M3 	FLASH: 384 	RAM: 32
• STM32F100VD 	Cortex-M3 	FLASH: 384 	RAM: 32
• STM32F100ZD 	Cortex-M3 	FLASH: 384 	RAM: 32
• STM32F100RE 	Cortex-M3 	FLASH: 512 	RAM: 32
• STM32F100VE 	Cortex-M3 	FLASH: 512 	RAM: 32
• STM32F100ZE 	Cortex-M3 	FLASH: 512 	RAM: 32

 
# STM32 Ultralow power devices VL
• STM32L100C6 	Cortex-M3 	FLASH: 32 	RAM: 4
• STM32L100R8 	Cortex-M3 	FLASH: 64 	RAM: 8
• STM32L100RB 	Cortex-M3 	FLASH: 128 	RAM: 10
• STM32L100RC 	Cortex-M3 	FLASH: 256 	RAM: 16
• STM32L100C6xxA 	Cortex-M3 	FLASH: 32 	RAM: 4
• STM32L100R8xxA 	Cortex-M3 	FLASH: 64 	RAM: 8
• STM32L100RBxxA 	Cortex-M3 	FLASH: 128 	RAM: 10

 
# STM32 Ultralow power devices MD
• STM32L151CB 	Cortex-M3 	FLASH: 128 	RAM: 16
• STM32L151RB 	Cortex-M3 	FLASH: 128 	RAM: 16
• STM32L151VB 	Cortex-M3 	FLASH: 128 	RAM: 16
• STM32L151C6 	Cortex-M3 	FLASH: 32 	RAM: 10
• STM32L151R6 	Cortex-M3 	FLASH: 32 	RAM: 10
• STM32L151C8 	Cortex-M3 	FLASH: 64 	RAM: 10
• STM32L151R8 	Cortex-M3 	FLASH: 64 	RAM: 10
• STM32L151V8 	Cortex-M3 	FLASH: 64 	RAM: 10
• STM32L152CB 	Cortex-M3 	FLASH: 128 	RAM: 16
• STM32L152RB 	Cortex-M3 	FLASH: 128 	RAM: 16
• STM32L152VB 	Cortex-M3 	FLASH: 128 	RAM: 16
• STM32L152C6 	Cortex-M3 	FLASH: 32 	RAM: 10
• STM32L152R6 	Cortex-M3 	FLASH: 32 	RAM: 10
• STM32L152C8 	Cortex-M3 	FLASH: 64 	RAM: 10
• STM32L152R8 	Cortex-M3 	FLASH: 64 	RAM: 10
• STM32L152V8 	Cortex-M3 	FLASH: 64 	RAM: 10
• STM32L151CBxxA 	Cortex-M3 	FLASH: 128 	RAM: 16
• STM32L151RBxxA 	Cortex-M3 	FLASH: 128 	RAM: 16
• STM32L151VBxxA 	Cortex-M3 	FLASH: 128 	RAM: 16
• STM32L151C6xxA 	Cortex-M3 	FLASH: 32 	RAM: 10
• STM32L151R6xxA 	Cortex-M3 	FLASH: 32 	RAM: 10
• STM32L151C8xxA 	Cortex-M3 	FLASH: 64 	RAM: 10
• STM32L151R8xxA 	Cortex-M3 	FLASH: 64 	RAM: 10
• STM32L151V8xxA 	Cortex-M3 	FLASH: 64 	RAM: 10
• STM32L152CBxxA 	Cortex-M3 	FLASH: 128 	RAM: 16
• STM32L152RBxxA 	Cortex-M3 	FLASH: 128 	RAM: 16
• STM32L152VBxxA 	Cortex-M3 	FLASH: 128 	RAM: 16
• STM32L152C6xxA 	Cortex-M3 	FLASH: 32 	RAM: 10
• STM32L152R6xxA 	Cortex-M3 	FLASH: 32 	RAM: 10
• STM32L152C8xxA 	Cortex-M3 	FLASH: 64 	RAM: 10
• STM32L152R8xxA 	Cortex-M3 	FLASH: 64 	RAM: 10
• STM32L152V8xxA 	Cortex-M3 	FLASH: 64 	RAM: 10

 
# STM32 Ultralow power devices MD+
• STM32L151QC 	Cortex-M3 	FLASH: 256 	RAM: 32
• STM32L151CC 	Cortex-M3 	FLASH: 256 	RAM: 32
• STM32L151RC 	Cortex-M3 	FLASH: 256 	RAM: 32
• STM32L151RCxxA 	Cortex-M3 	FLASH: 256 	RAM: 32
• STM32L151VC 	Cortex-M3 	FLASH: 256 	RAM: 32
• STM32L151VCxxA 	Cortex-M3 	FLASH: 256 	RAM: 32
• STM32L151UC 	Cortex-M3 	FLASH: 256 	RAM: 32
• STM32L151WC 	Cortex-M3 	FLASH: 256 	RAM: 32
• STM32L151ZC 	Cortex-M3 	FLASH: 256 	RAM: 32
• STM32L152CC 	Cortex-M3 	FLASH: 256 	RAM: 32
• STM32L152QC 	Cortex-M3 	FLASH: 256 	RAM: 32
• STM32L152ZC 	Cortex-M3 	FLASH: 256 	RAM: 32
• STM32L152RC 	Cortex-M3 	FLASH: 256 	RAM: 32
• STM32L152VC 	Cortex-M3 	FLASH: 256 	RAM: 32
• STM32L152WC 	Cortex-M3 	FLASH: 256 	RAM: 32
• STM32L152ZC 	Cortex-M3 	FLASH: 256 	RAM: 32

 
# STM32 Ultralow power devices HD
• STM32L151QD 	Cortex-M3 	FLASH: 384 	RAM: 48
• STM32L151RD 	Cortex-M3 	FLASH: 384 	RAM: 48
• STM32L151VD 	Cortex-M3 	FLASH: 384 	RAM: 48
• STM32L151ZD 	Cortex-M3 	FLASH: 384 	RAM: 48
• STM32L152QD 	Cortex-M3 	FLASH: 384 	RAM: 48
• STM32L152RD 	Cortex-M3 	FLASH: 384 	RAM: 48
• STM32L152VD 	Cortex-M3 	FLASH: 384 	RAM: 48
• STM32L152WD 	Cortex-M3 	FLASH: 384 	RAM: 48
• STM32L152ZD 	Cortex-M3 	FLASH: 384 	RAM: 48
• STM32L152RD 	Cortex-M3 	FLASH: 384 	RAM: 48
• STM32L152VD 	Cortex-M3 	FLASH: 384 	RAM: 48
• STM32L152WD 	Cortex-M3 	FLASH: 384 	RAM: 48
• STM32L151QE 	Cortex-M3 	FLASH: 512 	RAM: 80
• STM32L151RE 	Cortex-M3 	FLASH: 512 	RAM: 80
• STM32L151VE 	Cortex-M3 	FLASH: 512 	RAM: 80
• STM32L151ZE 	Cortex-M3 	FLASH: 512 	RAM: 80
• STM32L152QE 	Cortex-M3 	FLASH: 512 	RAM: 80
• STM32L152RE 	Cortex-M3 	FLASH: 512 	RAM: 80
• STM32L152VE 	Cortex-M3 	FLASH: 512 	RAM: 80
• STM32L152ZE 	Cortex-M3 	FLASH: 512 	RAM: 80
• STM32L162QD 	Cortex-M3 	FLASH: 384 	RAM: 48
• STM32L162RD 	Cortex-M3 	FLASH: 384 	RAM: 48
• STM32L162VD 	Cortex-M3 	FLASH: 384 	RAM: 48
• STM32L162ZD 	Cortex-M3 	FLASH: 384 	RAM: 48

 
# STM32 F-2 High-performance devices
• STM32F205RB 	Cortex-M3 	FLASH: 128 	RAM: 48
• STM32F205RC 	Cortex-M3 	FLASH: 256 	RAM: 80
• STM32F205RE 	Cortex-M3 	FLASH: 512 	RAM: 112
• STM32F205RF 	Cortex-M3 	FLASH: 768 	RAM: 112
• STM32F205RG 	Cortex-M3 	FLASH: 1024 	RAM: 112
• STM32F205VB 	Cortex-M3 	FLASH: 128 	RAM: 48
• STM32F205VC 	Cortex-M3 	FLASH: 256 	RAM: 80
• STM32F205VE 	Cortex-M3 	FLASH: 512 	RAM: 112
• STM32F205VF 	Cortex-M3 	FLASH: 768 	RAM: 112
• STM32F205VG 	Cortex-M3 	FLASH: 1024 	RAM: 112
• STM32F205ZC 	Cortex-M3 	FLASH: 256 	RAM: 80
• STM32F205ZE 	Cortex-M3 	FLASH: 512 	RAM: 112
• STM32F205ZF 	Cortex-M3 	FLASH: 768 	RAM: 112
• STM32F205ZG 	Cortex-M3 	FLASH: 1024 	RAM: 112
• STM32F207VC 	Cortex-M3 	FLASH: 256 	RAM: 112
• STM32F207VE 	Cortex-M3 	FLASH: 512 	RAM: 112
• STM32F207VF 	Cortex-M3 	FLASH: 768 	RAM: 112
• STM32F207VG 	Cortex-M3 	FLASH: 1024 	RAM: 112
• STM32F207ZC 	Cortex-M3 	FLASH: 256 	RAM: 112
• STM32F207ZE 	Cortex-M3 	FLASH: 512 	RAM: 112
• STM32F207ZF 	Cortex-M3 	FLASH: 768 	RAM: 112
• STM32F207ZG 	Cortex-M3 	FLASH: 1024 	RAM: 112
• STM32F207IC 	Cortex-M3 	FLASH: 256 	RAM: 112
• STM32F207IE 	Cortex-M3 	FLASH: 512 	RAM: 112
• STM32F207IF 	Cortex-M3 	FLASH: 768 	RAM: 112
• STM32F207IG 	Cortex-M3 	FLASH: 1024 	RAM: 112
• STM32F215RE 	Cortex-M3 	FLASH: 512 	RAM: 128
• STM32F215RG 	Cortex-M3 	FLASH: 1024 	RAM: 128
• STM32F215VE 	Cortex-M3 	FLASH: 512 	RAM: 128
• STM32F215VG 	Cortex-M3 	FLASH: 1024 	RAM: 128
• STM32F215ZE 	Cortex-M3 	FLASH: 512 	RAM: 128
• STM32F215ZG 	Cortex-M3 	FLASH: 1024 	RAM: 128
• STM32F217VE 	Cortex-M3 	FLASH: 512 	RAM: 128
• STM32F217VG 	Cortex-M3 	FLASH: 1024 	RAM: 128
• STM32F217ZE 	Cortex-M3 	FLASH: 512 	RAM: 128
• STM32F217ZG 	Cortex-M3 	FLASH: 1024 	RAM: 128
• STM32F217IE 	Cortex-M3 	FLASH: 512 	RAM: 128
• STM32F217IG 	Cortex-M3 	FLASH: 1024 	RAM: 128

 
# STM32F30x devices
• STM32F301C6 	Cortex-M4 	FLASH: 32 	RAM: 16
• STM32F301K6 	Cortex-M4 	FLASH: 32 	RAM: 16
• STM32F301R6 	Cortex-M4 	FLASH: 32 	RAM: 16
• STM32F301C8 	Cortex-M4 	FLASH: 64 	RAM: 16
• STM32F301K8 	Cortex-M4 	FLASH: 64 	RAM: 16
• STM32F301R8 	Cortex-M4 	FLASH: 64 	RAM: 16
• STM32F302C6 	Cortex-M4 	FLASH: 32 	RAM: 16
• STM32F302K6 	Cortex-M4 	FLASH: 32 	RAM: 16
• STM32F302R6 	Cortex-M4 	FLASH: 32 	RAM: 16
• STM32F302C8 	Cortex-M4 	FLASH: 64 	RAM: 16
• STM32F302K8 	Cortex-M4 	FLASH: 64 	RAM: 16
• STM32F302R8 	Cortex-M4 	FLASH: 64 	RAM: 16
• STM32F302CB 	Cortex-M4 	FLASH: 128 	RAM: 24
• STM32F302RB 	Cortex-M4 	FLASH: 128 	RAM: 24
• STM32F302VB 	Cortex-M4 	FLASH: 128 	RAM: 24
• STM32F302CC 	Cortex-M4 	FLASH: 256 	RAM: 32
• STM32F302RC 	Cortex-M4 	FLASH: 256 	RAM: 32
• STM32F302VC 	Cortex-M4 	FLASH: 256 	RAM: 32
• STM32F303CB 	Cortex-M4 	FLASH: 128 	RAM: 32
• STM32F303RB 	Cortex-M4 	FLASH: 128 	RAM: 32
• STM32F303VB 	Cortex-M4 	FLASH: 128 	RAM: 32
• STM32F303CC 	Cortex-M4 	FLASH: 256 	RAM: 40
• STM32F303RC 	Cortex-M4 	FLASH: 256 	RAM: 40
• STM32F303VC 	Cortex-M4 	FLASH: 256 	RAM: 40

 
# STM32F33x devices
• STM32F334K4 	Cortex-M4 	FLASH: 16 	RAM: 8
• STM32F334C4 	Cortex-M4 	FLASH: 16 	RAM: 8
• STM32F334R4 	Cortex-M4 	FLASH: 16 	RAM: 8
• STM32F334K6 	Cortex-M4 	FLASH: 32 	RAM: 10
• STM32F334C6 	Cortex-M4 	FLASH: 32 	RAM: 10
• STM32F334R6 	Cortex-M4 	FLASH: 32 	RAM: 10
• STM32F334K8 	Cortex-M4 	FLASH: 64 	RAM: 12
• STM32F334C8 	Cortex-M4 	FLASH: 64 	RAM: 12
• STM32F334R8 	Cortex-M4 	FLASH: 64 	RAM: 12

 
# STM32F358 devices
• STM32F358CC 	Cortex-M4 	FLASH: 256 	RAM: 48
• STM32F358RC 	Cortex-M4 	FLASH: 256 	RAM: 48
• STM32F358VC 	Cortex-M4 	FLASH: 256 	RAM: 48
• STM32F313CC 	Cortex-M4 	FLASH: 256 	RAM: 48
• STM32F313RC 	Cortex-M4 	FLASH: 256 	RAM: 48
• STM32F313VC 	Cortex-M4 	FLASH: 256 	RAM: 48

 
# STM32F37x devices
• STM32F372C8 	Cortex-M4 	FLASH: 64 	RAM: 32
• STM32F372R8 	Cortex-M4 	FLASH: 64 	RAM: 32
• STM32F372V8 	Cortex-M4 	FLASH: 64 	RAM: 32
• STM32F372CB 	Cortex-M4 	FLASH: 128 	RAM: 32
• STM32F372RB 	Cortex-M4 	FLASH: 128 	RAM: 32
• STM32F372VB 	Cortex-M4 	FLASH: 128 	RAM: 32
• STM32F372CC 	Cortex-M4 	FLASH: 256 	RAM: 32
• STM32F372RC 	Cortex-M4 	FLASH: 256 	RAM: 32
• STM32F372VC 	Cortex-M4 	FLASH: 256 	RAM: 32
• STM32F373C8 	Cortex-M4 	FLASH: 64 	RAM: 32
• STM32F373R8 	Cortex-M4 	FLASH: 64 	RAM: 32
• STM32F373V8 	Cortex-M4 	FLASH: 64 	RAM: 32
• STM32F373CB 	Cortex-M4 	FLASH: 128 	RAM: 32
• STM32F373RB 	Cortex-M4 	FLASH: 128 	RAM: 32
• STM32F373VB 	Cortex-M4 	FLASH: 128 	RAM: 32
• STM32F373CC 	Cortex-M4 	FLASH: 256 	RAM: 32
• STM32F373RC 	Cortex-M4 	FLASH: 256 	RAM: 32
• STM32F373VC 	Cortex-M4 	FLASH: 256 	RAM: 32
• STM32F378CC 	Cortex-M4 	FLASH: 256 	RAM: 32
• STM32F378RC 	Cortex-M4 	FLASH: 256 	RAM: 32
• STM32F378VC 	Cortex-M4 	FLASH: 256 	RAM: 32
• STM32F383CC 	Cortex-M4 	FLASH: 256 	RAM: 32
• STM32F383RC 	Cortex-M4 	FLASH: 256 	RAM: 32
• STM32F383VC 	Cortex-M4 	FLASH: 256 	RAM: 32

 
# STM32F40xx/41xx devices
• STM32F401CB 	Cortex-M4 	FLASH: 128 	RAM: 64
• STM32F401CC 	Cortex-M4 	FLASH: 256 	RAM: 64
• STM32F401RB 	Cortex-M4 	FLASH: 128 	RAM: 64
• STM32F401RC 	Cortex-M4 	FLASH: 256 	RAM: 64
• STM32F401VB 	Cortex-M4 	FLASH: 128 	RAM: 64
• STM32F401VC 	Cortex-M4 	FLASH: 256 	RAM: 64
• STM32F401CD 	Cortex-M4 	FLASH: 384 	RAM: 96
• STM32F401CE 	Cortex-M4 	FLASH: 512 	RAM: 96
• STM32F401RD 	Cortex-M4 	FLASH: 384 	RAM: 96
• STM32F401RE 	Cortex-M4 	FLASH: 512 	RAM: 96
• STM32F401VD 	Cortex-M4 	FLASH: 384 	RAM: 96
• STM32F401VE 	Cortex-M4 	FLASH: 512 	RAM: 96
• STM32F405OE 	Cortex-M4 	FLASH: 512 	RAM: 128
• STM32F405OG 	Cortex-M4 	FLASH: 1024 	RAM: 128
• STM32F405RG 	Cortex-M4 	FLASH: 1024 	RAM: 128
• STM32F405VG 	Cortex-M4 	FLASH: 1024 	RAM: 128
• STM32F405ZG 	Cortex-M4 	FLASH: 1024 	RAM: 128
• STM32F407VE 	Cortex-M4 	FLASH: 512 	RAM: 128
• STM32F407VG 	Cortex-M4 	FLASH: 1024 	RAM: 128
• STM32F407ZE 	Cortex-M4 	FLASH: 512 	RAM: 128
• STM32F407ZG 	Cortex-M4 	FLASH: 1024 	RAM: 128
• STM32F407IE 	Cortex-M4 	FLASH: 512 	RAM: 128
• STM32F407IG 	Cortex-M4 	FLASH: 1024 	RAM: 128
• STM32F415OG 	Cortex-M4 	FLASH: 1024 	RAM: 128
• STM32F415RG 	Cortex-M4 	FLASH: 1024 	RAM: 128
• STM32F415VG 	Cortex-M4 	FLASH: 1024 	RAM: 128
• STM32F415ZG 	Cortex-M4 	FLASH: 1024 	RAM: 128
• STM32F417VE 	Cortex-M4 	FLASH: 512 	RAM: 128
• STM32F417VG 	Cortex-M4 	FLASH: 1024 	RAM: 128
• STM32F417ZE 	Cortex-M4 	FLASH: 512 	RAM: 128
• STM32F417ZG 	Cortex-M4 	FLASH: 1024 	RAM: 128
• STM32F417IE 	Cortex-M4 	FLASH: 512 	RAM: 128
• STM32F417IG 	Cortex-M4 	FLASH: 1024 	RAM: 128

 
# STM32F42xx/43xx devices
• STM32F427IG 	Cortex-M4 	FLASH: 1024 	RAM: 192
• STM32F427II 	Cortex-M4 	FLASH: 2048 	RAM: 192
• STM32F427VG 	Cortex-M4 	FLASH: 1024 	RAM: 192
• STM32F427VI 	Cortex-M4 	FLASH: 2048 	RAM: 192
• STM32F427ZG 	Cortex-M4 	FLASH: 1024 	RAM: 192
• STM32F427ZI 	Cortex-M4 	FLASH: 2048 	RAM: 192
• STM32F437IG 	Cortex-M4 	FLASH: 1024 	RAM: 192
• STM32F437II 	Cortex-M4 	FLASH: 2048 	RAM: 192
• STM32F437VG 	Cortex-M4 	FLASH: 1024 	RAM: 192
• STM32F437VI 	Cortex-M4 	FLASH: 2048 	RAM: 192
• STM32F437ZG 	Cortex-M4 	FLASH: 1024 	RAM: 192
• STM32F437ZI 	Cortex-M4 	FLASH: 2048 	RAM: 192
• STM32F429VG 	Cortex-M4 	FLASH: 1024 	RAM: 192
• STM32F429ZG 	Cortex-M4 	FLASH: 1024 	RAM: 192
• STM32F429IG 	Cortex-M4 	FLASH: 1024 	RAM: 192
• STM32F429BG 	Cortex-M4 	FLASH: 1024 	RAM: 192
• STM32F429NG 	Cortex-M4 	FLASH: 1024 	RAM: 192
• STM32F429VI 	Cortex-M4 	FLASH: 2048 	RAM: 192
• STM32F429ZI 	Cortex-M4 	FLASH: 2048 	RAM: 192
• STM32F429II 	Cortex-M4 	FLASH: 2048 	RAM: 192
• STM32F429BI 	Cortex-M4 	FLASH: 2048 	RAM: 192
• STM32F429NI 	Cortex-M4 	FLASH: 2048 	RAM: 192
• STM32F439VG 	Cortex-M4 	FLASH: 1024 	RAM: 192
• STM32F439ZG 	Cortex-M4 	FLASH: 1024 	RAM: 192
• STM32F439IG 	Cortex-M4 	FLASH: 1024 	RAM: 192
• STM32F439BG 	Cortex-M4 	FLASH: 1024 	RAM: 192
• STM32F439NG 	Cortex-M4 	FLASH: 1024 	RAM: 192
• STM32F439VI 	Cortex-M4 	FLASH: 2048 	RAM: 192
• STM32F439ZI 	Cortex-M4 	FLASH: 2048 	RAM: 192
• STM32F439II 	Cortex-M4 	FLASH: 2048 	RAM: 192
• STM32F439BI 	Cortex-M4 	FLASH: 2048 	RAM: 192
• STM32F439NI 	Cortex-M4 	FLASH: 2048 	RAM: 192

 
# STM32W RF devices
• STM32W108HB 	Cortex-M3 	FLASH: 128 	RAM: 8
• STM32W108C8 	Cortex-M3 	FLASH: 64 	RAM: 8
• STM32W108CB 	Cortex-M3 	FLASH: 128 	RAM: 8
• STM32W108CZ 	Cortex-M3 	FLASH: 192 	RAM: 16
• STM32W108CC 	Cortex-M3 	FLASH: 256 	RAM: 16
"""

outf = open ("stm32-defs.mak", "w")
outf.write ("""\
# STM32 cpu & hardware definitions
# Automatically generated by mk-stm32-defs.py! Do not modify,
# modify mk-stm32-defs.py instead and re-run.

# Tables taken from http://www.atollic.com/index.php/targets/armtargetsupport/arm-stm
""")


outf.write ("""
# STM32.HW2CPU.[hardware] = [cpu]
""")

for hw in hwtable.split ("\n"):
    hw = hw.strip (u" \t•")
    if len (hw) == 0:
        continue
    hw = hw.lower ().split ()
    outf.write ("""\
STM32.HW2CPU.%(hw)s=%(cpu)s
""" % { "hw": hw [0], "cpu": hw [1], "core": hw [2]})

outf.write ("""
# STM32.CPUDEF.[microcontroller] = [core] [flash-size-kb] [ram-size-kb]
""")

for cpu in cputable.split ("\n"):
    cpu = cpu.strip (u" \t•")
    if len (cpu) == 0:
        continue
    if cpu [0] == '#':
        continue
    cpu = cpu.lower ().split ()
    if cpu [0][:6] != "stm32f":
        continue
    if cpu [1] == "cortex-m0+":
        cpu [1] = "cortex-m0plus"
    outf.write ("""\
STM32.CPUDEF.%(cpu)s = %(core)s %(flash)s %(ram)s
""" % { "cpu": cpu [0], "core": cpu [1], "flash": cpu [3], "ram": cpu [5]} )
